package com.jianhua.backend.service.impl;


import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.jianhua.backend.domain.entity.UserAddresses;
import com.jianhua.backend.mapper.UserAddressesMapper;
import com.jianhua.backend.service.UserAddressesService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * <p>
 * 存储用户在各场馆的配送地址信息 服务实现类
 * </p>
 *
 * @author author
 * @since 2025-07-02
 */
@Service
public class UserAddressesServiceImpl extends ServiceImpl<UserAddressesMapper, UserAddresses> implements UserAddressesService {

    @Autowired
    private UserAddressesMapper userAddressesMapper;

    @Override
    public List<UserAddresses> getUserAddressesByUserId(Integer userId) {
        return this.list(new LambdaQueryWrapper<UserAddresses>().eq(UserAddresses::getUserId, userId));
    }

    /**
     * 新增地址
     */
    @Override
    public boolean addAddress(UserAddresses address) {
        return this.save(address);
    }

    @Override
    public void updateAddress(UserAddresses address) {
        userAddressesMapper.updateById(address);
    }

    @Override
    public void deleteAddress(Integer id) {
        userAddressesMapper.deleteById(id);
    }
}
